<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"> <style>
	.KEYW {color: #933;}
	.COMM {color: #bbb; font-style: italic;}
	.NUMB {color: #393;}
	.STRN {color: #393;}
	.REGX {color: #339;}
	.line {border-right: 1px dotted #666; color: #666; font-style: normal;}
	</style></head><body><pre><span class='line'>  1</span> <span class="COMM">/** The minplayer namespace. */</span><span class="WHIT">
<span class='line'>  2</span> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">minplayer</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">minplayer</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>  3</span> 
<span class='line'>  4</span> </span><span class="COMM">/**
<span class='line'>  5</span>  * @constructor
<span class='line'>  6</span>  * @class This is a class used to keep track of flag states
<span class='line'>  7</span>  * which is used to control the busy cursor, big play button, among other
<span class='line'>  8</span>  * items in which multiple components can have an interest in hiding or
<span class='line'>  9</span>  * showing a single element on the screen.
<span class='line'> 10</span>  *
<span class='line'> 11</span>  * &lt;p>
<span class='line'> 12</span>  * &lt;strong>Usage:&lt;/strong>
<span class='line'> 13</span>  * &lt;pre>&lt;code>
<span class='line'> 14</span>  *   // Declare a flags variable.
<span class='line'> 15</span>  *   var flags = new minplayer.flags();
<span class='line'> 16</span>  *
<span class='line'> 17</span>  *   // Set the flag based on two components interested in the flag.
<span class='line'> 18</span>  *   flags.setFlag("component1", true);
<span class='line'> 19</span>  *   flags.setFlag("component2", true);
<span class='line'> 20</span>  *
<span class='line'> 21</span>  *   // Print out the value of the flags. ( Prints 3 )
<span class='line'> 22</span>  *   console.log(flags.flags);
<span class='line'> 23</span>  *
<span class='line'> 24</span>  *   // Now unset a single components flag.
<span class='line'> 25</span>  *   flags.setFlag("component1", false);
<span class='line'> 26</span>  *
<span class='line'> 27</span>  *   // Print out the value of the flags.
<span class='line'> 28</span>  *   console.log(flags.flags);
<span class='line'> 29</span>  *
<span class='line'> 30</span>  *   // Unset the other components flag.
<span class='line'> 31</span>  *   flags.setFlag("component2", false);
<span class='line'> 32</span>  *
<span class='line'> 33</span>  *   // Print out the value of the flags.
<span class='line'> 34</span>  *   console.log(flags.flags);
<span class='line'> 35</span>  * &lt;/code>&lt;/pre>
<span class='line'> 36</span>  * &lt;/p>
<span class='line'> 37</span>  */</span><span class="WHIT">
<span class='line'> 38</span> </span><span class="NAME">minplayer.flags</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 39</span> 
<span class='line'> 40</span> </span><span class="WHIT">  </span><span class="COMM">/** The flag. */</span><span class="WHIT">
<span class='line'> 41</span> </span><span class="WHIT">  </span><span class="NAME">this.flag</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 42</span> 
<span class='line'> 43</span> </span><span class="WHIT">  </span><span class="COMM">/** Id map to reference id with the flag index. */</span><span class="WHIT">
<span class='line'> 44</span> </span><span class="WHIT">  </span><span class="NAME">this.ids</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 45</span> 
<span class='line'> 46</span> </span><span class="WHIT">  </span><span class="COMM">/** The number of flags. */</span><span class="WHIT">
<span class='line'> 47</span> </span><span class="WHIT">  </span><span class="NAME">this.numFlags</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 48</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 49</span> 
<span class='line'> 50</span> </span><span class="COMM">/**
<span class='line'> 51</span>  * Sets a flag based on boolean logic operators.
<span class='line'> 52</span>  *
<span class='line'> 53</span>  * @param {string} id The id of the controller interested in this flag.
<span class='line'> 54</span>  * @param {boolean} value The value of this flag ( true or false ).
<span class='line'> 55</span>  */</span><span class="WHIT">
<span class='line'> 56</span> </span><span class="NAME">minplayer.flags.prototype.setFlag</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">id</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">value</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 57</span> 
<span class='line'> 58</span> </span><span class="WHIT">  </span><span class="COMM">// Define this id if it isn't present.</span><span class="WHIT">
<span class='line'> 59</span> </span><span class="WHIT">  </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">this.ids.hasOwnProperty</span><span class="PUNC">(</span><span class="NAME">id</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 60</span> </span><span class="WHIT">    </span><span class="NAME">this.ids</span><span class="PUNC">[</span><span class="NAME">id</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.numFlags</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 61</span> </span><span class="WHIT">    </span><span class="NAME">this.numFlags</span><span class="PUNC">++</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 62</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 63</span> 
<span class='line'> 64</span> </span><span class="WHIT">  </span><span class="COMM">// Use binary operations to keep track of the flag state</span><span class="WHIT">
<span class='line'> 65</span> </span><span class="WHIT">  </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">value</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 66</span> </span><span class="WHIT">    </span><span class="NAME">this.flag</span><span class="WHIT"> </span><span class="PUNC">|</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NUMB">1</span><span class="WHIT"> </span><span class="PUNC">&lt;&lt;</span><span class="WHIT"> </span><span class="NAME">this.ids</span><span class="PUNC">[</span><span class="NAME">id</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 67</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 68</span> </span><span class="WHIT">  </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 69</span> </span><span class="WHIT">    </span><span class="NAME">this.flag</span><span class="WHIT"> </span><span class="PUNC">&</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">~</span><span class="PUNC">(</span><span class="NUMB">1</span><span class="WHIT"> </span><span class="PUNC">&lt;&lt;</span><span class="WHIT"> </span><span class="NAME">this.ids</span><span class="PUNC">[</span><span class="NAME">id</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 70</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 71</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 72</span> </span></pre></body></html>